﻿using Event.Command;
using Event.Rule;
using PluginAPI.Core;
using PluginAPI.Core.Attributes;
using PluginAPI.Enums;
using PluginAPI.Events;
using Server_Management.Event;


namespace Server_Management.Main
{
    public class CodeLoad
    {
        public static CodeLoad Singleton { get; set; }

        [PluginConfig] public Config Config;



        [PluginEntryPoint("01 伺服器自助管理", "v1.0.0", "无人自助管理", "River")]
        [PluginPriority(LoadPriority.Medium)]
        public void Load()
        {
            if (!this.Config.IsEnable) return;

            Singleton = this;

            EventManager.RegisterEvents<VoteEvent>(this.Config.IsEnable);
            EventManager.RegisterEvents<WarheadControlEvent>(this.Config.IsEnable);
            EventManager.RegisterEvents<DateTimeNoticeEvent>(this.Config.IsEnable);
            EventManager.RegisterEvents<HintBroadCast>(this.Config.IsEnable);
            EventManager.RegisterEvents<KillLeaderBoradEvent>(this.Config.IsEnable);
            EventManager.RegisterEvents<VisitorEvent>(this.Config.IsEnable);

            Log.Info($"NWPluginAPI| 无人自助管理 | 加载");
        }

        [PluginUnload]
        public void UnLoad()
        {
            Singleton = null;

            EventManager.UnregisterEvents<VoteEvent>(this.Config.IsEnable);
            EventManager.UnregisterEvents<WarheadControlEvent>(this.Config.IsEnable);
            EventManager.UnregisterEvents<DateTimeNoticeEvent>(this.Config.IsEnable);
            EventManager.UnregisterEvents<HintBroadCast>(this.Config.IsEnable);
            EventManager.UnregisterEvents<KillLeaderBoradEvent>(this.Config.IsEnable);
            EventManager.UnregisterEvents<VisitorEvent>(this.Config.IsEnable);
        }
    }
}
